<template>
  <el-affix :offset="71">
    <el-menu
      class="border-0 theme-menu"
      :router="true"
      style="height: 90vh"
      active-text-color="#0050b3"
    >
      <template v-for="(menu, index) in menus" :key="index">
        <el-menu-item v-if="menu.children.length == 0" :index="menu.path">
          <div class="w-100 text-center">{{ menu.name }}</div>
        </el-menu-item>

        <el-sub-menu v-else :index="menu.path">
          <template #title>
            <div class="w-100 text-center">{{ menu.name }}</div>
          </template>
          <el-menu-item
            v-for="(submenu, index) in menu.children"
            :key="index"
            :index="menu.path+'/'+submenu.path"
            ><div class="w-100 text-center">
              {{ submenu.name }}
            </div></el-menu-item>
        </el-sub-menu>
      </template>
    </el-menu>
  </el-affix>
</template>

<script>
import { filterRouter } from "@/tools/perimission.js";
export default {
  name: "SpaceSiderBar",
  data() {
    return {
      menus: [],
    };
  },
  mounted() {
    this.menus = filterRouter(this.$router.options.routes);
  },
};
</script>

<style>
.theme-menu {
  background-image: linear-gradient(
    to bottom,
    rgb(201, 248, 207) 0%,
    rgb(113, 184, 125) 46%,
    rgb(30, 109, 53) 99%
  );
  background-size: auto;
  background-position: 0% 0%;
  background-repeat: repeat;
  background-color: rgba(0, 0, 0, 0);
}
</style>
